From d6fad9f57f9319326cb6188864523e07fe428b36 Mon Sep 17 00:00:00 2001 From: "kaf24@scramble.cl.cam.ac.uk" Date: Tue, 13 Jul 2004 14:41:24 +0000 Subject: [PATCH] bitkeeper revision 1.1071.1.3 (40f3f494hMH1GKUQuCB0vUKhJyfyoA) Add a conswitch command-line option to Xen. --- README.CD | 10 ++++++++++ docs/HOWTOs/Xen-HOWTO | 10 ++++++++++ xen/common/kernel.c | 6 ++++++ xen/drivers/char/console.c | 35 +++++++++++++++++++++++------------ 4 files changed, 49 insertions(+), 12 deletions(-) diff --git a/README.CD b/README.CD index c74f48beac..be17acfc54 100644 --- a/README.CD +++ b/README.CD @@ -307,6 +307,16 @@ that may be able to help diagnose problems: transmitted/received character. [NB. Default for this option is 'com1,tty'] + conswitch= + Specify how to switch serial-console input between + Xen and DOM0. The required sequence is CTRL- + pressed three times. Specifying '`' disables switching. + The specifies whether Xen should + auto-switch input to DOM0 when it boots -- if it is 'x' + then auto-switching is disabled. Any other value, or + omitting the character, enables auto-switching. + [NB. Default for this option is 'a'] + dom0_mem=xxx Set the initial amount of memory for domain0. pdb=xxx Enable the pervasive debugger. See docs/pdb.txt diff --git a/docs/HOWTOs/Xen-HOWTO b/docs/HOWTOs/Xen-HOWTO index 0c64ecd409..b0ec801659 100644 --- a/docs/HOWTOs/Xen-HOWTO +++ b/docs/HOWTOs/Xen-HOWTO @@ -253,6 +253,16 @@ The following is a list of command line arguments to pass to Xen: transmitted/received character. [NB. Default for this option is 'com1,tty'] + conswitch= + Specify how to switch serial-console input between + Xen and DOM0. The required sequence is CTRL- + pressed three times. Specifying '`' disables switching. + The specifies whether Xen should + auto-switch input to DOM0 when it boots -- if it is 'x' + then auto-switching is disabled. Any other value, or + omitting the character, enables auto-switching. + [NB. Default for this option is 'a'] + dom0_mem=xxx Set the maximum amount of memory for domain0. tbuf_size=xxx Set the size of the per-cpu trace buffers, in pages diff --git a/xen/common/kernel.c b/xen/common/kernel.c index a2fbd45dac..b90d467f9e 100644 --- a/xen/common/kernel.c +++ b/xen/common/kernel.c @@ -40,6 +40,11 @@ void start_of_day(void); /* opt_console: comma-separated list of console outputs. */ unsigned char opt_console[30] = "com1,vga"; +/* opt_conswitch: a character pair controlling console switching. */ +/* Char 1: CTRL+ is used to switch console input between Xen and DOM0 */ +/* Char 2: If this character is 'x', then do not auto-switch to DOM0 when it */ +/* boots. Any other value, or omitting the char, enables auto-switch */ +unsigned char opt_conswitch[5] = "a"; /* NB. '`' would disable switching. */ /* opt_com[12]: Config serial port with a string ,DPS,,. */ unsigned char opt_com1[30] = "", opt_com2[30] = ""; /* opt_dom0_mem: Kilobytes of memory allocated to domain 0. */ @@ -82,6 +87,7 @@ static struct { void *var; } opts[] = { { "console", OPT_STR, &opt_console }, + { "conswitch", OPT_STR, &opt_conswitch }, { "com1", OPT_STR, &opt_com1 }, { "com2", OPT_STR, &opt_com2 }, { "dom0_mem", OPT_UINT, &opt_dom0_mem }, diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 26362bdee0..b1887fa1fb 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -17,6 +17,8 @@ #include #include +extern unsigned char opt_console[], opt_conswitch[]; + static int xpos, ypos; static unsigned char *video = __va(0xB8000); @@ -227,17 +229,18 @@ long read_console_ring(unsigned long str, unsigned int count, unsigned cmd) static char serial_rx_ring[SERIAL_RX_SIZE]; static unsigned int serial_rx_cons, serial_rx_prod; -/* CTRL-a switches input direction between Xen and DOM0. */ -#define CTRL_A 0x01 +/* CTRL- switches input direction between Xen and DOM0. */ +#define SWITCH_CODE (opt_conswitch[0]-'a'+1) static int xen_rx = 1; /* FALSE => serial input passed to domain 0. */ static void switch_serial_input(void) { static char *input_str[2] = { "DOM0", "Xen" }; xen_rx = !xen_rx; - printk("*** Serial input -> %s " - "(type 'CTRL-a' three times to switch input to %s).\n", - input_str[xen_rx], input_str[!xen_rx]); + if ( SWITCH_CODE != 0 ) + printk("*** Serial input -> %s " + "(type 'CTRL-%c' three times to switch input to %s).\n", + input_str[xen_rx], opt_conswitch[0], input_str[!xen_rx]); } static void __serial_rx(unsigned char c, struct pt_regs *regs) @@ -264,20 +267,20 @@ static void __serial_rx(unsigned char c, struct pt_regs *regs) static void serial_rx(unsigned char c, struct pt_regs *regs) { - static int ctrl_a_count = 0; + static int switch_code_count = 0; - if ( c == CTRL_A ) + if ( (SWITCH_CODE != 0) && (c == SWITCH_CODE) ) { - /* We eat CTRL-a in groups of three to switch console input. */ - if ( ++ctrl_a_count == 3 ) + /* We eat CTRL- in groups of 3 to switch console input. */ + if ( ++switch_code_count == 3 ) { switch_serial_input(); - ctrl_a_count = 0; + switch_code_count = 0; } } else { - ctrl_a_count = 0; + switch_code_count = 0; } /* Finally process the just-received character. */ @@ -395,7 +398,6 @@ void set_printk_prefix(const char *prefix) void init_console(void) { - extern unsigned char opt_console[]; unsigned char *p; /* Where should console output go? */ @@ -418,6 +420,15 @@ void console_endboot(int disable_vga) { if ( disable_vga ) vgacon_enabled = 0; + + /* + * If user specifies so, we fool the switch routine to redirect input + * straight back to Xen. I use this convoluted method so we still print + * a useful 'how to switch' message. + */ + if ( opt_conswitch[1] == 'x' ) + xen_rx = !xen_rx; + /* Serial input is directed to DOM0 by default. */ switch_serial_input(); } -- 2.30.2